<!DOCTYPE html>
<html lang="en-us">

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />

  	<meta property="og:title" content=" Jmeter对数据库的增删改查 &middot;  我的博客" />
  	<meta property="og:site_name" content="我的博客" />
  	<meta property="og:url" content="/my_technology/12/" />
    
    
  	<meta property="og:type" content="article" />

    <meta property="og:article:published_time" content="2020-06-11T20:20:42&#43;08:00" />

    
    

  <title>
     Jmeter对数据库的增删改查 &middot;  我的博客
  </title>

    <meta name="description" content="这里是付佳康的个人博客" />

    <meta name="HandheldFriendly" content="True" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />

    <link rel="shortcut icon" href="/my_technology/images/favicon.ico">
	  <link rel="apple-touch-icon" href="/my_technology/images/apple-touch-icon.png" />
    
    <link rel="stylesheet" type="text/css" href="/my_technology/css/screen.css" />
    <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Merriweather:300,700,700italic,300italic|Open+Sans:700,400|Inconsolata" />


    
      
          <link href="/my_technology/index.xml" rel="alternate" type="application/rss+xml" title="我的博客" />
      
      
    
    <meta name="generator" content="Hugo 0.68.3" />

    <link rel="canonical" href="/my_technology/12/" />

     
</head>
<body class="nav-closed">
<div id="particles-js"></div>
  


 <div class="site-wrapper">



<header class="main-header " style="background-image: url(/my_technology/images/user.jpg)">

    <nav class="main-nav overlay clearfix">
        
            <a class="blog-logo" href="/my_technology/"><img src="/my_technology/images/user.png" alt="Blog Logo" /></a>
        
        
    </nav>
<div class="vertical">
        <div class="main-header-content inner">
            <h1 class="page-title">
              <a class="btn-bootstrap-2" href="#content">我的博客</a>
          </h1>
          <h2 class="page-description">这里是付佳康的个人博客</h2>
        </div>
</div>
    <a class="scroll-down icon-arrow-left" href="#content"><span class="hidden">Scroll Down</span></a>
</header>

  <main id="content" class="content" role="main">


  <article class="post ">

    <header class="post-header">
        <h1 class="post-title">Jmeter对数据库的增删改查</h1>
        <section class="post-meta">
        
         
        </section>
    </header>

    <section class="post-content">
      <pre><code>1.准备mysql-connector-java-5.1.18-bin.jar（mysql架包）
2.在测试计划中添加数据库jar包
</code></pre><p><img src="../%E6%B7%BB%E5%8A%A0%E6%95%B0%E6%8D%AE%E5%BA%93%E6%9E%B6%E5%8C%85.png" alt="添加数据库架包"></p>
<pre><code>在线程组添加配置原件中的 JDBC Connection Configuration 并进行配置
    Database URL：jdbc:mysql://数据库连接:端口号/库名?characterEncoding=utf-8&amp;allowMultiQueries=true
        库名后添加：?characterEncoding=utf-8&amp;allowMultiQueries=true  表示防止乱码和允许多条sql语句执行
</code></pre><p><img src="../JDBC_Con%E6%93%8D%E4%BD%9C.png" alt="JDBC_Con操作"></p>
<pre><code>在线程住添加取样器中的 JDBC Request,在这里进行增删改查操作
</code></pre><p><img src="../JDBC%E5%A2%9E%E5%88%A0%E6%94%B9%E6%9F%A5.png" alt="JDBC增删改查">
<img src="../JDBC%E5%A2%9E%E5%88%A0%E6%94%B9%E6%9F%A51.png" alt="JDBC增删改查"></p>
<pre><code>若系统中有禅道，需要在此电脑管理-》服务》关闭mysqlzt
    否则报错Response message:java.sql.SQLException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: YES))

在线程住添加监听器中的察看结果树，察看进行的增删改查操作（响应数据）
</code></pre><pre><code>对sql语句使用的变量概念：
    在线程组下添加配置原件中的用户定义的变量
        在JDBC Request中如果写入sql语句 select * from teacher where number=${number};
        在用户定义的变量名称要与${}中的变量名一致，值自己定义
</code></pre><pre><code>Statement(状态通道)和 PreparedStatement(预状态通道):
    区别：
        在对数据库只执行一次性存储的时候，用Statement(状态通道)，Statement(状态通道)每次执行sql语句，相关数据库都要执行sql语句的编译
        PreparedStatement(预状态通道)对于批量处理可以大大提高效率，也叫JDBC存储过程，对象的开销比Statement(状态通道)大
</code></pre><p><img src="../%E9%A2%84%E7%8A%B6%E6%80%81%E9%80%9A%E9%81%93.png" alt="预状态通道"></p>
<pre><code>使用PreparedStatement(预状态通道)用英文问号?来进行占位，多个?对应多个值
</code></pre><p><img src="../%E9%A2%84%E7%8A%B6%E6%80%81%E5%8D%A0%E4%BD%8D.png" alt="预状态占位"></p>
<pre><code>使用用户变量进行PreparedStatement(预状态通道):
    在Paramenter Values中用${变量名}要与用户定义的变量中定义的名称一致，变量名不能相同，可以放具体常量值也可以放变量
</code></pre><p><img src="../%E9%A2%84%E7%8A%B6%E6%80%81%E5%8F%98%E9%87%8F.png" alt="预状态变量"></p>
<pre><code>使用Variable names(返回结果) 和 Result variable name（创建一个变量存储返回的结果）与不使用在Debug sampler(调试取样器)中的区别
</code></pre><p><img src="../%E4%BD%BF%E7%94%A8%E8%BF%94%E5%9B%9E%E7%BB%93%E6%9E%9C.png" alt="使用返回结果">
<img src="../%E4%BD%BF%E7%94%A8%E8%BF%94%E5%9B%9E%E7%BB%93%E6%9E%9C%E7%AD%89.png" alt="使用返回结果等"></p>
<p><img src="../%E4%B8%8D%E4%BD%BF%E7%94%A8%E8%BF%94%E5%9B%9E%E7%BB%93%E6%9E%9C.png" alt="不使用返回结果">
<img src="../%E4%B8%8D%E4%BD%BF%E7%94%A8%E8%BF%94%E5%9B%9E%E7%BB%93%E6%9E%9C%E7%AD%89.png" alt="不使用返回结果等"></p>

    </section>


  <footer class="post-footer">


    
    <figure class="author-image">

        <a class="img" href="/my_technology/" style="background-image: url(/my_technology/images/user.png)"><span class="hidden">付佳康</span></a>
    </figure>
    

    <section class="author">

  <p>付佳康</p>
  

</section>


    
    <section class="share">
      <h4>Share this page</h4>
      <a class="icon-twitter" style="font-size: 1.4em" href="https://twitter.com/share?text=Jmeter%e5%af%b9%e6%95%b0%e6%8d%ae%e5%ba%93%e7%9a%84%e5%a2%9e%e5%88%a0%e6%94%b9%e6%9f%a5&amp;url=%2fmy_technology%2f12%2f"
          onclick="window.open(this.href, 'twitter-share', 'width=550,height=235');return false;">
          <span class="hidden">Twitter</span>
      </a>
      <a class="icon-facebook" style="font-size: 1.4em" href="https://www.facebook.com/sharer/sharer.php?u=%2fmy_technology%2f12%2f"
          onclick="window.open(this.href, 'facebook-share','width=580,height=296');return false;">
          <span class="hidden">Facebook</span>
      </a>
      <a class="icon-google-plus" style="font-size: 1.4em" href="https://plus.google.com/share?url=%2fmy_technology%2f12%2f"
         onclick="window.open(this.href, 'google-plus-share', 'width=490,height=530');return false;">
          <span class="hidden">Google+</span>
      </a>
    </section>
    

    
    
    

  </footer>
</article>

</main>
    <footer class="site-footer clearfix">
        <section class="copyright"><a href="">我的博客</a> </section>
        
        <section class="poweredby">Proudly generated by <a class="icon-hugo" href="https://gohugo.io">HUGO</a>, with <a class="icon-theme" href="https://github.com/syui/hugo-theme-air">hugo-theme-air</a> theme</section>
        
    </footer>
    </div>
    <script type="text/javascript" src="/my_technology/js/jquery.js"></script>
    <script type="text/javascript" src="/my_technology/js/jquery.fitvids.js"></script>
    <script type="text/javascript" src="/my_technology/js/index.js"></script>
    <script src="/my_technology/js/particles.min.js"></script>
    <script src="/my_technology/js/particles.js"></script>  

</body>
</html>

